function transect_bathymetry(ctr,All)

%Load and plot grid data
R=region_data_all(ctr);
fname=['../../generate_profiles/data/data_',R.name,'.mat'];
load(fname,'C','P');    
subplot('position',[0.05 0.1 0.85 0.5]); hold on;

tr=All.transect;
plt=find(tr(:,1)==ctr);
lines=unique(tr(plt,2));

offset=3*nanstd(C.T(lines(1)).z);
offset=round(offset/10)*10; 

for ct=1:length(lines),
    %correct the time-direction of region 7 transects 1:4
    if ctr==7 && ct<5
        C.T(lines(ct)).idist=-C.T(lines(ct)).idist;
        C.T(lines(ct)).dist=-C.T(lines(ct)).dist;
        P.T(lines(ct)).idist=-P.T(lines(ct)).idist;
        P.T(lines(ct)).dist=-P.T(lines(ct)).dist;
    end 
    z=-smoothPH(C.T(lines(ct)).z,11);
    dist=C.T(lines(ct)).dist;
    pl=find(isnan(z)==0 & isnan(dist)==0); 
    z=z(pl);
    dist=dist(pl);
    mz=interp1(dist,z,0,'linear','extrap');
    plot(dist,z-mz+offset*ct,'k','linewidth',1);
    plot(0,offset*ct,'ro','markersize',12,'linewidth',2); 
    try,
        distbm=P.T(lines(ct)).BM(1).idist; %location of the BM on one side
        plot(distbm,interp1(dist,z-mz+offset*ct,distbm),'r.','markersize',22);
    end;
    try,
        distbm=P.T(lines(ct)).BM(2).idist; %location of the BM on the other side, if it exists
        plot(distbm,interp1(dist,z-mz+offset*ct,distbm),'r.','markersize',22);
    end;
end;
axis tight; h4=axis;
for ct=1:length(lines);
    text(h4(2),offset*ct,num2str(lines(ct),2),'fontsize',15,'linewidth',1);
end;

%name
axis([h4(1)-diff(h4(1:2))*0.05 h4(2:4)]); h4=axis;
plot([0 0],h4(3:4),'k--','linewidth',1);
%text(h4(1),h4(4)-0.05*diff(h4(3:4)),R.name,'fontsize',18); 
text(h4(1),h4(4)-0.05*diff(h4(3:4)),'bathymetry','fontsize',18); 
axis off;

%unit bar
dx=diff(h4(1:2));
dy=diff(h4(3:4));
x=[1 1]*h4(1)+0.001*dx;
y=[h4(4)-0.15*dy h4(4)-0.15*dy-offset];
plot(x,y,'k','linewidth',1.5);
if dy>8*offset;
    label=round(linspace(0,offset,2));
end;
if dy<=8*offset & dy>4*offset;
    label=round(linspace(0,offset,3));
end;
if dy<=4*offset;
    label=round(linspace(0,offset,5));
end;

%labels
for ct=1:length(label);
    plot([x(1) x(1)+0.005*dx],y(2)*[1 1]+label(ct),'k','linewidth',1.5);
    text(x(1)+0.01*dx,y(2)+label(ct),[num2str(label(ct)),' m'],'linewidth',1.5,'fontsize',12);
end;

%make x-axis
subplot('position',[0.05 0.098 0.85 0.001]); 
axis([h4(1:2) 0 1]);
font(gca,15);
h=xlabel('distance (km)'); font(h,15);



